
import javax.swing.*;
import java.awt.*; 
import java.util.*;

import java.awt.event.*; //wegen MouseListener

public class MouseConnection implements MouseListener, MouseMotionListener
{
    ZeichenPanel panel;

     public MouseConnection(ZeichenPanel panel)
     {
         this.panel = panel;
     }

    
    public void mousePressed(MouseEvent e){
        System.out.println("Mouse pressed:"+e.getX() +", "+e.getY());
        System.out.println("Tile: "+mausKoordinateXinTileX(e.getX()) +", "+mausKoordinateYinTileY(e.getY()));
        int x= mausKoordinateXinTileX(e.getX());
        int y= mausKoordinateYinTileY(e.getY());
        panel.fenster.controller.buttonGedrueckt(x,y);
    }

    public void mouseDragged(MouseEvent e) {
//         System.out.println("Mouse dragged: "+e.getX() +", "+e.getY());
    }

    public void mouseReleased(MouseEvent e) {
//         System.out.println("Mouse released: "+e.getX() +", "+e.getY());
    }

    public void mouseClicked(MouseEvent e) {
//         System.out.println("Mouse clicked: "+e.getX() +", "+e.getY());
    }

    public void mouseMoved(MouseEvent e){
//         System.out.println("Mouse moved: "+e.getX() +", "+e.getY());
    }

    public void mouseEntered(MouseEvent e){
//         System.out.println("Mouse entered: "+e.getX() +", "+e.getY());
    }

    public void mouseExited(MouseEvent e) {
//         System.out.println("Mouse exited: "+e.getX() +", "+e.getY());
    }
    
    int mausKoordinateXinTileX(int mausX) {
        return mausX/panel.tileBreite;
    }
    int mausKoordinateYinTileY(int mausY) {
        return mausY/panel.tileHoehe;
    }
    
   
}
